import * as Blockly from 'blockly/core';


const MODELS = {
    DeepSeek: [
        ['deepseek-chat', 'deepseek-chat'],
        ['deepseek-reasoner', 'deepseek-reasoner']
    ],
    ChatGPT: [
        ['gpt-4.5-preview', 'gpt-4.5-preview'],
        ['gpt-4o', 'gpt-4o'],
        ['gpt-4o-mini', 'gpt-4o-mini'],
        ['gpt-4o-realtime-preview', 'gpt-4o-realtime-preview'],
        ['gpt-4o-mini-realtime-preview', 'gpt-4o-mini-realtime-preview'],
        ['o1', 'o1'],
        ['o1-mini', 'o1-mini'],
        ['o1-preview', 'o1-preview'],
        ['o3-mini', 'o3-mini'],
        ['gpt-4-turbo', 'gpt-4-turbo'],
        ['gpt-4', 'gpt-4'],
        ['gpt-3.5-turbo', 'gpt-3.5-turbo'],
        ['gpt-3.5-turbo-instruct', 'gpt-3.5-turbo-instruct']
    ],
    AliyunBaiLian: [
        ['qwen-max', 'qwen-max'],
        ['qwen-plus', 'qwen-plus'],
        ['qwen-turbo', 'qwen-turbo'],
        ['qwen-long', 'qwen-long'],
        ['qwen-omni-turbo', 'qwen-omni-turbo'],
        ['qwen-vl-max', 'qwen-vl-max'],
        ['qwen-vl-plus', 'qwen-vl-plus'],
        ['qwen-vl-ocr', 'qwen-vl-ocr'],
        ['qwen-audio-turbo', 'qwen-audio-turbo'],
        ['qwen-audio-asr', 'qwen-audio-asr'],
        ['qwen-math-plus', 'qwen-math-plus'],
        ['qwen-math-turbo', 'qwen-math-turbo'],
        ['qwen-coder-plus', 'qwen-coder-plus'],
        ['qwen-coder-turbo', 'qwen-coder-turbo'],
        ['qwen-mt-plus', 'qwen-mt-plus'],
        ['qwen-mt-turbo', 'qwen-mt-turbo'],
        ['qwq-32b-preview', 'qwq-32b-preview'],
        ['qwen2.5-14b-instruct-1m', 'qwen2.5-14b-instruct-1m'],
        ['qwen2.5-7b-instruct-1m', 'qwen2.5-7b-instruct-1m'],
        ['qwen2.5-72b-instruct', 'qwen2.5-72b-instruct'],
        ['qwen2.5-32b-instruct', 'qwen2.5-32b-instruct'],
        ['qwen2.5-14b-instruct', 'qwen2.5-14b-instruct'],
        ['qwen2.5-7b-instruct', 'qwen2.5-7b-instruct'],
        ['qwen2.5-3b-instruct', 'qwen2.5-3b-instruct'],
        ['qwen2.5-1.5b-instruct', 'qwen2.5-1.5b-instruct'],
        ['qwen2.5-0.5b-instruct', 'qwen2.5-0.5b-instruct'],
        ['qwen2-72b-instruct', 'qwen2-72b-instruct'],
        ['qwen2-57b-a14b-instruct', 'qwen2-57b-a14b-instruct'],
        ['qwen2-7b-instruct', 'qwen2-7b-instruct'],
        ['qwen2-1.5b-instruct', 'qwen2-1.5b-instruct'],
        ['qwen2-0.5b-instruct', 'qwen2-0.5b-instruct'],
        ['qwen1.5-110b-chat', 'qwen1.5-110b-chat'],
        ['qwen1.5-72b-chat', 'qwen1.5-72b-chat'],
        ['qwen1.5-32b-chat', 'qwen1.5-32b-chat'],
        ['qwen1.5-14b-chat', 'qwen1.5-14b-chat'],
        ['qwen1.5-7b-chat', 'qwen1.5-7b-chat'],
        ['qwen1.5-1.8b-chat', 'qwen1.5-1.8b-chat'],
        ['qwen1.5-0.5b-chat', 'qwen1.5-0.5b-chat'],
        ['qwen-72b-chat', 'qwen-72b-chat'],
        ['qwen-14b-chat', 'qwen-14b-chat'],
        ['qwen-7b-chat', 'qwen-7b-chat'],
        ['qwen-1.8b-chat', 'qwen-1.8b-chat'],
        ['qwen-1.8b-longcontext-chat', 'qwen-1.8b-longcontext-chat'],
        ['qvq-72b-preview', 'qvq-72b-preview'],
        ['qwen2.5-vl-72b-instruct', 'qwen2.5-vl-72b-instruct'],
        ['qwen2.5-vl-7b-instruct', 'qwen2.5-vl-7b-instruct'],
        ['qwen2.5-vl-3b-instruct', 'qwen2.5-vl-3b-instruct'],
        ['qwen2-vl-72b-instruct', 'qwen2-vl-72b-instruct'],
        ['qwen2-vl-7b-instruct', 'qwen2-vl-7b-instruct'],
        ['qwen2-vl-2b-instruct', 'qwen2-vl-2b-instruct'],
        ['qwen-vl-v1', 'qwen-vl-v1'],
        ['qwen-vl-chat-v1', 'qwen-vl-chat-v1'],
        ['qwen2-audio-instruct', 'qwen2-audio-instruct'],
        ['qwen-audio-chat', 'qwen-audio-chat'],
        ['qwen2.5-math-72b-instruct', 'qwen2.5-math-72b-instruct'],
        ['qwen2.5-math-7b-instruct', 'qwen2.5-math-7b-instruct'],
        ['qwen2.5-math-1.5b-instruct', 'qwen2.5-math-1.5b-instruct'],
        ['qwen2-math-72b-instruct', 'qwen2-math-72b-instruct'],
        ['qwen2-math-7b-instruct', 'qwen2-math-7b-instruct'],
        ['qwen2-math-1.5b-instruct', 'qwen2-math-1.5b-instruct'],
        ['qwen2.5-coder-32b-instruct', 'qwen2.5-coder-32b-instruct'],
        ['qwen2.5-coder-14b-instruct', 'qwen2.5-coder-14b-instruct'],
        ['qwen2.5-coder-7b-instruct', 'qwen2.5-coder-7b-instruct'],
        ['qwen2.5-coder-3b-instruct', 'qwen2.5-coder-3b-instruct'],
        ['qwen2.5-coder-1.5b-instruct', 'qwen2.5-coder-1.5b-instruct'],
        ['qwen2.5-coder-0.5b-instruct', 'qwen2.5-coder-0.5b-instruct'],
        ['deepseek-r1', 'deepseek-r1'],
        ['deepseek-v3', 'deepseek-v3'],
        ['deepseek-r1-distill-qwen-1.5b', 'deepseek-r1-distill-qwen-1.5b'],
        ['deepseek-r1-distill-qwen-7b', 'deepseek-r1-distill-qwen-7b'],
        ['deepseek-r1-distill-qwen-14b', 'deepseek-r1-distill-qwen-14b'],
        ['deepseek-r1-distill-qwen-32b', 'deepseek-r1-distill-qwen-32b'],
        ['deepseek-r1-distill-llama-8b', 'deepseek-r1-distill-llama-8b'],
        ['deepseek-r1-distill-llama-70b', 'deepseek-r1-distill-llama-70b'],
        ['llama3.3-70b-instruct', 'llama3.3-70b-instruct'],
        ['llama3.2-3b-instruct', 'llama3.2-3b-instruct'],
        ['llama3.2-1b-instruct', 'llama3.2-1b-instruct'],
        ['llama3.1-405b-instruct', 'llama3.1-405b-instruct'],
        ['llama3.1-70b-instruct', 'llama3.1-70b-instruct'],
        ['llama3.1-8b-instruct', 'llama3.1-8b-instruct'],
        ['llama3-70b-instruct', 'llama3-70b-instruct'],
        ['llama3-8b-instruct', 'llama3-8b-instruct'],
        ['llama2-13b-chat-v2', 'llama2-13b-chat-v2'],
        ['llama2-7b-chat-v2', 'llama2-7b-chat-v2'],
        ['llama3.2-90b-vision-instruct', 'llama3.2-90b-vision-instruct'],
        ['llama3.2-11b-vision', 'llama3.2-11b-vision'],
        ['baichuan2-turbo', 'baichuan2-turbo'],
        ['baichuan2-13b-chat-v1', 'baichuan2-13b-chat-v1'],
        ['baichuan2-7b-chat-v1', 'baichuan2-7b-chat-v1'],
        ['baichuan-7b-v1', 'baichuan-7b-v1'],
        ['chatglm3-6b', 'chatglm3-6b'],
        ['chatglm-6b-v2', 'chatglm-6b-v2'],
        ['yi-large', 'yi-large'],
        ['yi-medium', 'yi-medium'],
        ['yi-large-rag', 'yi-large-rag'],
        ['yi-large-turbo', 'yi-large-turbo'],
        ['abab6.5g-chat', 'abab6.5g-chat'],
        ['abab6.5t-chat', 'abab6.5t-chat'],
        ['abab6.5s-chat', 'abab6.5s-chat'],
        ['ziya-llama-13b-v1', 'ziya-llama-13b-v1'],
        ['belle-llama-13b-2m-v1', 'belle-llama-13b-2m-v1'],
        ['chatyuan-large-v2', 'chatyuan-large-v2'],
        ['billa-7b-sft-v1', 'billa-7b-sft-v1']
    ],
    BaiChuanAI: [
        ['Baichuan4-Turbo', 'Baichuan4-Turbo'],
        ['Baichuan4-Air', 'Baichuan4-Air'],
        ['Baichuan4', 'Baichuan4'],
        ['Baichuan3-Turbo', 'Baichuan3-Turbo'],
        ['Baichuan3-Turbo-128k', 'Baichuan3-Turbo-128k'],
        ['Baichuan2-Turbo', 'Baichuan2-Turbo']
    ],
    SiliconFlow: [
        ['Pro/deepseek-ai/DeepSeek-R1', 'Pro/deepseek-ai/DeepSeek-R1'],
        ['Pro/deepseek-ai/DeepSeek-V3', 'Pro/deepseek-ai/DeepSeek-V3'],
        ['deepseek-ai/DeepSeek-R1', 'deepseek-ai/DeepSeek-R1'],
        ['deepseek-ai/DeepSeek-V3', 'deepseek-ai/DeepSeek-V3'],
        ['deepseek-ai/DeepSeek-R1-Distill-Qwen-32B', 'deepseek-ai/DeepSeek-R1-Distill-Qwen-32B'],
        ['deepseek-ai/DeepSeek-R1-Distill-Qwen-14B', 'deepseek-ai/DeepSeek-R1-Distill-Qwen-14B'],
        ['deepseek-ai/DeepSeek-R1-Distill-Qwen-7B', 'deepseek-ai/DeepSeek-R1-Distill-Qwen-7B'],
        ['deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B', 'deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B'],
        ['Qwen/QVQ-72B-Preview', 'Qwen/QVQ-72B-Preview'],
        ['deepseek-ai/DeepSeek-V2.5', 'deepseek-ai/DeepSeek-V2.5'],
        ['Qwen/QwQ-32B-Preview', 'Qwen/QwQ-32B-Preview'],
        ['Qwen/Qwen2.5-Coder-32B-Instruct', 'Qwen/Qwen2.5-Coder-32B-Instruct'],
        ['Qwen/Qwen2-VL-72B-Instruct', 'Qwen/Qwen2-VL-72B-Instruct'],
        ['Qwen/Qwen2.5-72B-Instruct-128K', 'Qwen/Qwen2.5-72B-Instruct-128K'],
        ['deepseek-ai/deepseek-vl2', 'deepseek-ai/deepseek-vl2'],
        ['Qwen/Qwen2.5-72B-Instruct', 'Qwen/Qwen2.5-72B-Instruct'],
        ['Qwen/Qwen2.5-32B-Instruct', 'Qwen/Qwen2.5-32B-Instruct'],
        ['Qwen/Qwen2.5-14B-Instruct', 'Qwen/Qwen2.5-14B-Instruct'],
        ['Qwen/Qwen2.5-7B-Instruct', 'Qwen/Qwen2.5-7B-Instruct'],
        ['Qwen/Qwen2.5-Coder-7B-Instruct', 'Qwen/Qwen2.5-Coder-7B-Instruct'],
        ['TeleAI/TeleChat2', 'TeleAI/TeleChat2'],
        ['internlm/internlm2_5-20b-chat', 'internlm/internlm2_5-20b-chat'],
        ['internlm/internlm2_5-7b-chat', 'internlm/internlm2_5-7b-chat'],
        ['Qwen/Qwen2-7B-Instruct', 'Qwen/Qwen2-7B-Instruct'],
        ['Qwen/Qwen2-1.5B-Instruct', 'Qwen/Qwen2-1.5B-Instruct'],
        ['THUDM/glm-4-9b-chat', 'THUDM/glm-4-9b-chat'],
        ['THUDM/chatglm3-6b', 'THUDM/chatglm3-6b'],
        ['Pro/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B', 'Pro/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B'],
        ['Pro/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B', 'Pro/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B'],
        ['Pro/Qwen/Qwen2-VL-7B-Instruct', 'Pro/Qwen/Qwen2-VL-7B-Instruct'],
        ['Pro/Qwen/Qwen2.5-7B-Instruct', 'Pro/Qwen/Qwen2.5-7B-Instruct'],
        ['Pro/Qwen/Qwen2-7B-Instruct', 'Pro/Qwen/Qwen2-7B-Instruct'],
        ['Pro/Qwen/Qwen2-1.5B-Instruct', 'Pro/Qwen/Qwen2-1.5B-Instruct'],
        ['Pro/THUDM/glm-4-9b-chat', 'Pro/THUDM/glm-4-9b-chat']
    ],
    LingYiWanWu: [
        ['yi-lightning', 'yi-lightning']
    ],
    MoonShot: [
        ['kimi-latest', 'kimi-latest'],
        ['moonshot-v1-8k', 'moonshot-v1-8k'],
        ['moonshot-v1-32k', 'moonshot-v1-32k'],
        ['moonshot-v1-128k', 'moonshot-v1-128k']
    ],
    TencentHunYuan: [
        ['hunyuan-turbos-latest', 'hunyuan-turbos-latest'],
        ['hunyuan-turbo', 'hunyuan-turbo'],
        ['hunyuan-turbo-latest', 'hunyuan-turbo-latest'],
        ['hunyuan-large', 'hunyuan-large'],
        ['hunyuan-large-longcontext', 'hunyuan-large-longcontext'],
        ['hunyuan-standard-256K', 'hunyuan-standard-256K'],
        ['hunyuan-standard', 'hunyuan-standard'],
        ['hunyuan-lite', 'hunyuan-lite'],
        ['hunyuan-code', 'hunyuan-code']
    ],
    VolcEngine: [
        ['doubao-1.5-pro-32k-250115', 'doubao-1.5-pro-32k-250115'],
        ['doubao-1.5-pro-256k-250115', 'doubao-1.5-pro-256k-250115'],
        ['doubao-1.5-lite-32k-250115', 'doubao-1.5-lite-32k-250115'],
        ['deepseek-r1-250120', 'deepseek-r1-250120'],
        ['deepseek-r1-distill-qwen-32b-250120', 'deepseek-r1-distill-qwen-32b-250120'],
        ['deepseek-v3-241226', 'deepseek-v3-241226'],
        ['doubao-pro-4k-240515', 'doubao-pro-4k-240515'],
        ['doubao-pro-32k-241215', 'doubao-pro-32k-241215'],
        ['doubao-pro-32k-240828', 'doubao-pro-32k-240828'],
        ['doubao-pro-32k-240615', 'doubao-pro-32k-240615'],
        ['doubao-pro-128k-240628', 'doubao-pro-128k-240628'],
        ['doubao-pro-128k-240515', 'doubao-pro-128k-240515'],
        ['doubao-pro-256k-240828', 'doubao-pro-256k-240828'],
        ['doubao-lite-4k-240328', 'doubao-lite-4k-240328'],
        ['doubao-lite-32k-240828', 'doubao-lite-32k-240828'],
        ['doubao-lite-32k-240628', 'doubao-lite-32k-240628'],
        ['doubao-lite-32k-240428', 'doubao-lite-32k-240428'],
        ['moonshot-v1-8k', 'moonshot-v1-8k'],
        ['moonshot-v1-32k', 'moonshot-v1-32k'],
        ['moonshot-v1-128k', 'moonshot-v1-128k'],
        ['chatglm3-130b-fc-v1.0', 'chatglm3-130b-fc-v1.0'],
        ['chatglm3-130-fin-v1.0-update', 'chatglm3-130-fin-v1.0-update'],
        ['mistral-7b-instruct-v0.2', 'mistral-7b-instruct-v0.2']
    ],
    Custom: [
        ['-', '-']
    ]
};

const LLM_HUE = 0;

export const mixly_lib_llm_init = {
    init: function () {
        this.appendDummyInput()
            .setAlign(Blockly.ALIGN_LEFT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_INIT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME');
        this.appendValueInput('KEY')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_API_KEY);
        this.appendValueInput('MODEL')
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_MODEL);
        this.appendValueInput('PROMPT')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_SYSTEM_PROMPT);
        this.setInputsInline(false);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_models = {
    init: function () {
        this.appendDummyInput()
            .setAlign(Blockly.ALIGN_LEFT)
            .appendField(new Blockly.FieldDropdown(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_PROVIDERS), 'PROVIDER')
            .appendField(new Blockly.FieldDependentDropdown('PROVIDER', MODELS, MODELS['DeepSeek']), 'MODEL');
        this.setInputsInline(true);
        this.setOutput(true);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_prompts_template = {
    init: function () {
        this.appendDummyInput()
            .setAlign(Blockly.ALIGN_LEFT)
            .appendField(new Blockly.FieldDropdown(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_PROMPTS_TEMPLATE), 'PROMPT');
        this.setInputsInline(true);
        this.setOutput(true);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_set_api_key = {
    init: function () {
        this.appendValueInput('KEY')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_SET_API_KEY);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_set_timeout = {
    init: function () {
        this.appendValueInput('NUM')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_SET_TIMEOUT);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_set_max_retries = {
    init: function () {
        this.appendValueInput('NUM')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_SET_MAX_RETRIES);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_set_system_prompt = {
    init: function () {
        this.appendValueInput('PROMPT')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_SET_SYSTEM_PROMPT);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_set_model = {
    init: function () {
        this.appendValueInput('MODEL')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_SELECT_MODEL);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_model_provider = {
    init: function () {
        this.appendDummyInput()
            .appendField(new Blockly.FieldDropdown(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_PROVIDERS), 'PROVIDER');
        this.setInputsInline(true);
        this.setOutput(true);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_set_custom_model = {
    init: function () {
        this.appendDummyInput()
            .setAlign(Blockly.ALIGN_RIGHT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_SELECT_MODEL);
        this.appendValueInput('PROVIDER')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_MODEL_PROVIDER);
        this.appendValueInput('MODEL')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_MODEL_NAME);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_set_custom_url = {
    init: function () {
        this.appendValueInput('STR')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_SET_CUSTOM_URL);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_enable_history_messages = {
    init: function () {
        this.appendValueInput('BOOL')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_ENABLE_HISTORY_MESSAGES);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_set_history_messages_num = {
    init: function () {
        this.appendValueInput('NUM')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_SET_HISTORY_MESSAGES_NUM);
        this.setInputsInline(true);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_chat = {
    init: function () {
        this.appendDummyInput()
            .setAlign(Blockly.ALIGN_LEFT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHAT);
        this.appendValueInput('PROMPT')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_USER_PROMPT);
        this.appendValueInput('NUM')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_MAX_TOKENS);
        this.setInputsInline(false);
        this.setOutput(true);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_chat_stream = {
    init: function () {
        this.appendDummyInput()
            .setAlign(Blockly.ALIGN_LEFT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHAT_STREAM);
        this.appendValueInput('PROMPT')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_USER_PROMPT);
        this.appendValueInput('NUM')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_MAX_TOKENS);
        this.appendValueInput('CALLBACK')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CONTENT_CALLBACK);
        this.setInputsInline(false);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_chat_stream2 = {
    init: function () {
        this.appendDummyInput()
            .setAlign(Blockly.ALIGN_LEFT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHAT_STREAM);
        this.appendValueInput('PROMPT')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_USER_PROMPT);
        this.appendValueInput('NUM')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_MAX_TOKENS);
        this.appendValueInput('CALLBACK')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CONTENT_CALLBACK);
        this.setInputsInline(false);
        this.setOutput(true);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_chat_stream_reasoning = {
    init: function () {
        this.appendDummyInput()
            .setAlign(Blockly.ALIGN_LEFT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHAT_STREAM);
        this.appendValueInput('PROMPT')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_USER_PROMPT);
        this.appendValueInput('NUM')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_MAX_TOKENS);
        this.appendValueInput('CALLBACK1')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CONTENT_CALLBACK);
        this.appendValueInput('CALLBACK2')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_REASONING_CONTENT_CALLBACK);
        this.setInputsInline(false);
        this.setPreviousStatement(true, null);
        this.setNextStatement(true, null);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};

export const mixly_lib_llm_chat_stream_reasoning2 = {
    init: function () {
        this.appendDummyInput()
            .setAlign(Blockly.ALIGN_LEFT)
            //.appendField(new Blockly.FieldImage(require('../media/llm2.svg'), 20, 20))
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHATBOT)
            .appendField(new Blockly.FieldTextInput('chatbot'), 'NAME')
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CHAT_STREAM);
        this.appendValueInput('PROMPT')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_USER_PROMPT);
        this.appendValueInput('NUM')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_MAX_TOKENS);
        this.appendValueInput('CALLBACK1')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_CONTENT_CALLBACK);
        this.appendValueInput('CALLBACK2')
            .setCheck(null)
            .setAlign(Blockly.ALIGN_RIGHT)
            .appendField(Blockly.Msg.MIXLY_LIB_ARDUINO_LLM_REASONING_CONTENT_CALLBACK);
        this.setInputsInline(false);
        this.setOutput(true);
        this.setColour(LLM_HUE);
        this.setTooltip('');
        this.setHelpUrl('');
    }
};